<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../style/css/user/center.css">
    <script src="../../style/js/jquery-1.8.3.js" type="text/javascript"></script>
    <script src="../../style/js/ajaxfileupload.js"></script>
    <script type="text/javascript">
        var userId;


        function update() {
            var oldPwd = $("#oldPwd").val();
            var newPwd = $("#newPwd").val();
            var repeatPwd = $("#repeatPwd").val();

            if (newPwd!==repeatPwd){
                alert("两次输入密码不同,请重新输入")
                $("#newPwd").val("");
                $("#repeatPwd").val("");
            }else if (oldPwd===newPwd){
                alert("新密码与原密码相同")
                $("#newPwd").val("");
                $("#repeatPwd").val("");
            }else {
                $.post("../../user/setPassword", $("#msgForm").serialize(), function (res) {
                    if (res.code === 200) {
                        alert(res.msg);
                        top.location.replace("../user_login.html")
                    } else if (res.code === 201) {
                        alert(res.msg);
                    } else if (res.code === 500) {
                        alert(res.msg);
                    } else {
                        alert("修改失败");
                    }
                })
            }
        }
    </script>
</head>
<body>
<div class="public_m1">
    <div class="public_m2">账户安全</div>
    <!--照片和内容-->
    <div class="zp_nrm">
        <!--right-->
        <form id="msgForm">
            <input type="hidden" id="imgUrl" name="newFileName">
            <input type="hidden" id="id" name="id">
            <div class="zp_nrm_r">
                <p><em>原密码：</em><input type="password" id="oldPwd" name="oldPwd"></p>
                <p><em>新密码：</em><input type="password" id="newPwd" name="newPwd"></p>
                <p><em>确认新密码：</em><input type="password" id="repeatPwd" name="repeatPwd"></p>
                <a href="javaScript:void(0)" class="public_m3" onclick="update()">确认修改</a>
            </div>
        </form>
    </div>
</div>
</body>
</html>
